package logic

import (
	"context"
	"shop_srv/shop"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type CreateActivityLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCreateActivityLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateActivityLogic {
	return &CreateActivityLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *CreateActivityLogic) CreateActivity(req *types.CreateActivityRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	create, err := l.svcCtx.ShopSrv.CreateActivity(l.ctx, &shop.CreateActivityRequest{
		GoodsId:       req.GoodsId,
		ActivityPrice: float32(req.ActivityPrice),
		Progress:      req.Progress,
		Countdown:     req.Countdown,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "活动创建成功",
		Code:    200,
		Data:    create,
	}, nil
}
